package com.runing.controller;


import com.runing.config.ResponseWrapper;
import com.runing.entity.Message;
import com.runing.service.impl.MessageServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lel
 * @since 2021-03-13
 */
@RestController
@RequestMapping("/message")
@Api(tags = "发布通知")
public class MessageController {

    @Autowired
    MessageServiceImpl messageService;

    @ApiOperation("发布通知")
    @PostMapping("/addMsg")
    public ResponseWrapper addMsg(@RequestBody Message message){
        ResponseWrapper wrapper = messageService.addMsg(message);
        return wrapper;
    }

    @ApiOperation("查询所有通知或查询一条通知")
    @ApiImplicitParam(name = "mid",value = "通知id")
    @GetMapping("/findMsg")
    public ResponseWrapper findMsg(@RequestParam(name = "mid",required = false)Integer mid){
        ResponseWrapper wrapper = messageService.findMsg(mid);
        return wrapper;
    }
}

